Fix empty device list on recent macOS (collapsed ScrollView + missing mic permission)#28
Open
e-gons wants to merge 1 commit into
Open
Fix empty device list on recent macOS (collapsed ScrollView + missing mic permission)#28e-gons wants to merge 1 commit into
e-gons wants to merge 1 commit into
Conversation
- self-size MenuBarExtra ScrollView; device rows were collapsing to zero height inside the self-sizing menu bar window, hiding all speakers/headphones/microphones - request microphone permission (NSMicrophoneUsageDescription + AVCaptureDevice.requestAccess) so input devices are visible; macOS hides input streams from apps without mic access Amp-Thread-ID: https://ampcode.com/threads/T-019f147f-7c38-7317-a209-e452190dd76c Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On recent macOS versions the menu bar popover shows the mode toggle and volume slider but no devices at all — Speakers, Headphones, and Microphones sections are all blank, even though devices exist and the default output works (the volume slider is functional).
This PR fixes two independent regressions that surfaced as macOS evolved.
1. Device rows collapsed to zero height
The device list is wrapped in a
ScrollViewwith only.frame(maxHeight: 420). AScrollViewhas no intrinsic content height, so inside the self-sizingMenuBarExtra(...).menuBarExtraStyle(.window)window it collapses to ~0pt, hiding every device row between the header and footer. (The header/footer have intrinsic sizes, so they still render — which is why the popover looked half-empty.)Fix: measure the content height via a
GeometryReader+PreferenceKeyand size theScrollViewto its content, capped at 420pt (scrolls beyond that).2. Input devices hidden without Microphone permission
macOS hides audio input streams from apps that lack Microphone permission, so
hasStreams(input:)returns 0 for every device and no microphones are ever listed. The app had noNSMicrophoneUsageDescriptionand never requested access, so it could never be granted.Fix: add
NSMicrophoneUsageDescriptionand request mic access on launch viaAVCaptureDevice.requestAccess(for: .audio), refreshing the device list once the user responds. The request only fires when status is.notDetermined, so users are prompted at most once.Testing
Notes